package com.rb;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 * Created by walker on 17-7-28.
 *
 */
public class GeneratorMain
{
    public static void main(String[] args){
        Connection con = 1==1?local():remote();
        //EntityGenerator.generator(con, "com.ry.sail.entity", "t_user_session","t_user_bucket", "t_brand","t_banner", "t_app_config","t_cart","t_goods","t_order","t_order_item","t_pay_log","t_role","t_seller","t_user","t_user_address","t_user_coupon","t_user_role");
        EntityGenerator.generator(con, "com.rb.entity",  "t_user");
    }

    private static Connection local(){
        String url = "jdbc:mysql://localhost:3306/sail" ;
        String username = "root" ;
        String password = "root" ;
        Connection con = null;
        try{
            con = DriverManager.getConnection(url , username , password ) ;
        }catch(Exception se){
            System.out.println("数据库连接失败！");
            se.printStackTrace() ;
            return null;
        }
        return con;
    }

    private static Connection remote(){
        String url = "jdbc:mysql://rm-uf633ei00q53s3l8mo.mysql.rds.aliyuncs.com:3306/sail" ;
        String username = "root" ;
        String password = "root!2017" ;
        Connection con = null;
        try{
            con = DriverManager.getConnection(url , username , password ) ;
        }catch(Exception se){
            System.out.println("数据库连接失败！");
            se.printStackTrace() ;
            return null;
        }
        return con;
    }
}
